#!/bin/bash

#
# This script compiles and runs AmurCalendar2014 application 
# 	for Unix/Linux-based systems
#
# Author: Samantha Choy
# Date: August 11, 2014
# For ICS314 final project

##### Functions #####
function wait_enter {
	echo ""
	read -p "Please press enter to continue..." nothing
	}


##### Variables ######
PROJECT=../AmurCalendar2014
BINMAIN=$PROJECT/bin
MAINFILE=$BINMAIN/main/EventInputI.class
TEXTFILE=applist_v3.txt
URL=https://code.google.com/p/ics314-sum14-amur-cal/


##### Main #####

##### **Take this out before turning in** #####
echo "Checking Java version for testing..."
echo ""
java -version
echo ""
echo ""
##### **Take this out before turning in** #####

echo "Compiling AmurCalendar2014 application..."

echo "Compiling classes..."
javac -sourcepath $PROJECT/src/ -d $BINMAIN @$TEXTFILE
echo "..."

echo "Compiling main..."
javac -sourcepath $PROJECT/src/ -d $BINMAIN -classpath $BINMAIN $PROJECT/src/main/EventInputI.java
echo "..."
echo ""

if [ -e "$MAINFILE" ]; then 
	echo "Done!"
	echo "Starting AmurCalendar2014..."
	sleep 3

	clear

	java -classpath $BINMAIN main.EventInputI
else 
	echo ""
	echo "Error: Classes could not be compiled." 
	echo "Unable to start AmurCalendar2014..."
	echo "Please go to $URL to report error."
fi

echo ""
echo ""
$(wait_enter)

PROJECT=
BINMAIN=
MAINFILE=
TEXTFILE=
URL=
